package com.simtop.service.impl;

import com.simtop.common.ServerResponse;
import com.simtop.dao.EchartsDao;
import com.simtop.pojo.Echarts;
import com.simtop.pojo.Echarts2;
import com.simtop.pojo.Echarts3;
import com.simtop.service.EchartsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class EchartsServiceImpl implements EchartsService {

    @Autowired
    private EchartsDao echartsDao;

    @Override
    public ServerResponse<List<Echarts>> selectEightProUser() {
        List list =  echartsDao.selectEightProUser();
        return ServerResponse.createBySuccess(list);
    }

    @Override
    public ServerResponse<List<Echarts2>> selectRoleUser() {
        List<Echarts2> echartsList = echartsDao.selectRoleUser();
        return ServerResponse.createBySuccess(echartsList);
    }

    /**
     * 修改(新加了实验)
     * @return
     */
    @Override
    public ServerResponse<Echarts3> selectScoreUser() {
        /**
         * 旧的成绩表
         */
        Echarts3 echarts = echartsDao.selectScoreUser();
        /**
         * 新的成绩表
         */
        Echarts3 echarts1 = echartsDao.selectRobotStepScore();
        //赋值
        Echarts3 echarts3 = new Echarts3();
        echarts3.setC0(echarts.getC0()+echarts1.getC0());
        echarts3.setC1(echarts.getC1()+echarts1.getC1());
        echarts3.setC2(echarts.getC2()+echarts1.getC2());
        echarts3.setC3(echarts.getC3()+echarts1.getC3());
        echarts3.setC4(echarts.getC4()+echarts1.getC4());
        return ServerResponse.createBySuccess(echarts3);
    }
}